<template>
	<view>
			<!-- !!!!! placeholder 在ios表现有偏移 建议使用 第一种样式 -->
			<view class="cu-form-group margin-top">
				<textarea maxlength="-1" :disabled="modalName!=null" @input="textareaAInput" placeholder="请输入回复内容"></textarea>
			</view>
		
		  <view class="box margin-top-20" style=" padding: 20upx;">
			 
				<button @click="postForm" class="cu-btn block bg-blue margin-tb-sm lg">
				<text :class="loadding==1?'cuIcon-loading2 cuIconfont-spin':'cuIconfont-spin'"></text> {{publish_text}}</button>
			 
			</view>
			
		 </view>
</template>


<script>
	import beeApp from '../../beeApp.js'
	export default {
		data() {
			return {
				    item: {},
                    publish_text: "确认提交",
                    pid: 0,
					modalName:null,
					loadding:0,
                    type: "general",
                    content: "",
                    placeholder: "",
                    is_publish: 0,
                    comment_id: 0,
                    act: "add"	 
			}
		},
		onLoad(option) {
		    var _this = this;
			this.placeholder = option.placeholder;
			this.pid = option.pid;
			this.comment_id = option.comment_id;
			if (option.type) {
				this.type = option.type;
			}
		},
		methods: {
			   textareaAInput(e) {
				 this.content = e.detail.value
			   },
                postForm: function() {
                    var _this = this;
                    if (_this.loadding == 1) {
                        return;
                    }
                   
					if(this.content==""){
					  beeApp.alert("请输入回复内容");
					  return;
				   }
				    _this.publish_text = "发布中....";
                    _this.loadding = 1;
					var data={
						 pid : this.pid,
						 type: this.type,
						 method:"POST",
						 content:this.content,
						 to_comment_id:this.comment_id,
					};
                    beeApp.api("sns/comment/add", data, function(res) {
                        //var data= JSON.parse(res);
                        if (res.code != 200) {
                            beeApp.alert(res.msg);
                            _this.loadding = 0;
                        } else {
                            beeApp.setPageData("pages/topic/detail",{reload:1})
                            //首页列表点赞数结束
                            beeApp.alert("恭喜你，回复成功", function() {
                                uni.navigateBack();
                            });
                        }
                        _this.publish_text = "确认发布";
                    });
                }
		   
				
	   }
		
}
</script>


